package com.wehealth.parse;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.wehealth.dm.DM_PlanDay;
import com.wehealth.dm.Doctor;

public class ParseJson {
	/**
	 * 获取咨询医生列表
	 * @param drJson
	 * @return
	 */
	public static List<Doctor> getDrList(String drJson){
		List<Doctor> dr_List = null;
		try {
			JSONObject jsonOBject = new JSONObject(drJson);
			dr_List = new ArrayList<Doctor>();
			String shopJson = jsonOBject.getString("result");
			Gson gson = new Gson();
			Type listType = new TypeToken<LinkedList<Doctor>>()
			{
			}.getType();
			LinkedList<Doctor> channels = gson.fromJson(shopJson, listType);
			for (Iterator<Doctor> iterator = channels.iterator(); iterator.hasNext();)
			{
				dr_List.add(iterator.next());
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return dr_List;
	}
	
	
	
	public static List<DM_PlanDay> GetPlanList(String strJSON){
		List<DM_PlanDay> planList = null;
		try {
			JSONObject jsonOBject = new JSONObject(strJSON);
			planList = new ArrayList<DM_PlanDay>();
			String jsonContent = jsonOBject.getString("result");
			Gson gson = new Gson();
			Type listType = new TypeToken<LinkedList<DM_PlanDay>>()
			{
			}.getType();
			LinkedList<DM_PlanDay> channels = gson.fromJson(jsonContent, listType);
			for (Iterator<DM_PlanDay> iterator = channels.iterator(); iterator.hasNext();)
			{
				planList.add(iterator.next());
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return planList;
	}
	

	
}
